<template>
  <div class="rightCommonWrapper" :class="{ isShrink: state.isShrink }">
    <IrrigationProgress />
    <PumpGateDetails />
    <slot></slot>
    <div class="shrinkBtn" @click="handleClickShrink">
      <MenuUnfoldOutlined :rotate="state.iconRotate" />
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { reactive, watch } from 'vue';
  import { MenuUnfoldOutlined } from '@ant-design/icons-vue';
  import IrrigationProgress from './irrigationProgress/index.vue';
  import PumpGateDetails from './pumpGateDetails/index.vue';

  defineOptions({ name: 'RightCommon' });

  const props = defineProps({
    isCollapse: { type: Boolean },
  });

  const state = reactive({
    isShrink: false,
    iconRotate: 0,
  });

  // 一键收起侧边栏
  watch(
    () => props.isCollapse,
    (val) => {
      state.isShrink = val;
      state.iconRotate = val ? 180 : 0;
    }
  );

  const handleClickShrink = () => {
    state.isShrink = !state.isShrink;
    state.iconRotate = state.isShrink ? 180 : 0;
  };
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .rightCommonWrapper {
    width: 650px;
    height: 978px;
    position: absolute;
    top: 60px;
    right: 60px;
    z-index: 200;
    transition: all 0.5s;
    transform: translateX(0px);
    padding: 4px 8px 8px 8px;
    display: grid;
    grid-template-rows: minmax(490px, 50%) minmax(480px, 48%);
    grid-row-gap: 6px;
    /* .shrinkBtn {
      width: 28px;
      height: 28px;
      background: rgba(204, 243, 228, 0.8);
      color: #5ac99b;
      border-radius: 4px;
      position: absolute;
      top: 0px;
      right: 1080px;
      z-index: 100;
      font-size: 18px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0.6;
      transition: all 0.5s;
      transform: translateX(0px);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      &:hover {
        background: rgba(204, 243, 228, 0.8);
        opacity: 1;
      }
    } */
  }
  .isShrink {
    transform: translateX(650px);
  }
</style>
